#include <iostream>
#include <vector>
using namespace std;
const int N=1e3+10;
vector<int> ret;
int a[N];
void dfs1(int root,int tail)
{
	if(root>tail)
		return;
	int left=root+1,right=tail;
	while(left<=right && a[left]<a[root])
		left++;
	while(right>=left && a[right]>=a[root])
		right--;
	if(left-right!=1)
		return;
	
	dfs1(root+1,right);
	dfs1(left,tail);
	ret.push_back(a[root]);
	
}
void dfs2(int root,int tail)
{
	if(root>tail)
		return;
	int left=root+1,right=tail;
	while(left<=right && a[right]<a[root])
		right--;
	while(right>=left && a[left]>=a[root])
		left++;
	if(left-right!=1)
		return;
	
	dfs2(root+1,right);
	dfs2(left,tail);
	ret.push_back(a[root]);	
}
int main()
{
	int n;
	cin>>n;
	for(int i=1;i<=n;i++)
	{
		cin>>a[i];
	}
	
	dfs1(1,n);
	
	if(ret.size()!=n)
	{
		ret.clear();
		dfs2(1,n);
	}
	if(ret.size()!=n)
	{
//		cout<<ret.size()<<endl;
		cout<<"NO"<<endl;
	}
	else{
		cout<<"YES"<<endl;
		if(ret.size()==0)
			return 0;
		cout<<ret[0];
		for(int i=1;i<ret.size();i++)
		{
			cout<<' '<<ret[i];
		}
	}
	return 0;
}
